// pages/order/order.js
var app = getApp()
Page({
  data: {
    navindex: 0,
    According: false,
    nav: [
      { txt: '待付款' },
      { txt: '待发货' },
      { txt: '待收货' },
      { txt: '已完成' },
    ],
    orderdeil: [
      { urls:'/images/banner3.jpg', number: "E2017080356236", name: '飞利浦（PHILIPS）迷你车载充电器快充', shuliang:'2', fuwu: '已完成', price: '20.22'},
      { urls: '/images/banner3.jpg', number: "E2017080356236", name: '飞利浦（PHILIPS）迷你车载充电器快充', shuliang: '2', fuwu: '已完成', price: '20.22' },
      { urls: '/images/banner3.jpg', number: "E2017080356236", name: '飞利浦（PHILIPS）迷你车载充电器快充', shuliang: '2', fuwu: '已完成', price: '20.22' },
      { urls: '/images/banner3.jpg', number: "E2017080356236", name: '飞利浦（PHILIPS）迷你车载充电器快充', shuliang: '2', fuwu: '已完成', price: '20.22' }
    ],
    indicatorDots: true,
    autoplay: true,
    interval: 5000,
    duration: 1000,
    userInfo: {}
  },
  //底部
  click: function (e) {
    var id = e.currentTarget.dataset.id;
    console.log(id)
    this.setData({
      navindex: id
    })
    // wx.request({
    //   url: 'https://yunying.135k.com/api/goods/myposs',
    //   data: {
    //   },
    //   success: function (res) {
    //     that.setData({
    //       list: res.data.data
    //     })
    //   }
    // })
  },
  // kdxq: function (e) {
  //   app.navTo('../orderdeil/orderdeil')
  // },
  //提醒发货
  showok: function () {
    wx.showToast({
      title: '已成功提醒卖家发货',
      icon: 'success',
      duration: 2000
    })
  },
  //确认收货
  confirm: function () {
    wx.showToast({
      title: '确认收货成功',
      icon: 'success',
      duration: 2000
    })
  },
  //删除订单
  deletes: function (e) {
    var that = this;
    var id = e.currentTarget.id;
    var del = this.data.orderdeil;
    wx.showModal({
      title: '删除订单',
      content: '确定要删除订单？',
      success: function (res) {
        if (res.confirm) {
          // console.log('用户点击确定')
          for (var i in del) {
            if (i == id) {
              del.splice(id, 1);
            }
          }
          that.setData({
            orderdeil: del
          })
        } else if (res.cancel) {
          // console.log('用户点击取消')

        }
      }
    })
  },
  cancel:function(e){
    var that = this;
    var id = e.currentTarget.id;
    var del = this.data.orderdeil;
    wx.showModal({
      title: '取消订单',
      content: '确定要取消订单？',
      success:function(res){
        if (res.confirm) {
          // console.log('用户点击确定')
          for (var i in del) {
            if (i == id) {
              del.splice(id, 1);
            }
          }
          that.setData({
            orderdeil: del
          })
        } else if (res.cancel) {
          // console.log('用户点击取消')

        }
      }
    })
  },
  bindViewTap: function () {

  },
  onLoad: function (e) {
 
  },
  onShow: function () {
    let that = this;
    var HQgoods = that.data.orderdeil;
    if (HQgoods.length == 0) {
      that.setData({
        According: true,
      })
    } else {
      that.setData({
        According: false,
      })
    }
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})  